package com.lcm.openapi.resolver;

import com.lcm.openapi.common.exception.ServiceException;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class FileSystemResolver implements DataSourceResolver {

    @Override
    public Reader getReader(String source) {
        InputStream is = null;
        BufferedReader br = null;
        try{
            is = new FileInputStream(source);
            br = new BufferedReader(new InputStreamReader(is ,StandardCharsets.UTF_8));
        }catch (IOException e){
            throw new ServiceException("资源文件不存在或读取失败");
        }
        return br;
    }
}
